<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>写信</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="${resource }/css/bootstrap.css" />
		<link rel="stylesheet" href="${resource }/css/selectpage.css" />
		<link rel="stylesheet" href="${resource }/editor/default.css" />
		<script type="text/javascript" src="${resource }/js/jquery-2.1.1.min.js"></script>
		<script type="text/javascript" src="${resource }/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="${resource }/js/selectpage.js"></script>
		<script type="text/javascript" src="${resource }/editor/kindeditor-all.js" ></script>
		<script type="text/javascript" src="${resource }/editor/zh-CN.js" ></script>
		<script>
	        KindEditor.ready(function(K) {
	               window.editor = K.create('#editor_id');
	        });
		</script>
	</head>

	<body>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-sm-4">
				<h2>站内信</h2>
				<ol class="breadcrumb">
					<li>
						<a href="tomain.do">主页</a>
					</li>
					<li>
						<strong>写信</strong>
					</li>
				</ol>
			</div>
		</div>
		<hr />
		<form id="myform" method="post" name="myform">
			<div class="form-group">
				<label class="col-sm-2 control-label" style="text-align: center;margin-bottom: 15px;">标题</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" style="margin-bottom: 15px;" name="mailTitle" value="${mail.mailTitle }">
				</div>
			</div>
			<div style="margin-top: 30px;">
				<div class="form-group">
					<label class="col-sm-2 control-label" style="text-align: center;margin-right: 15px;">收件人</label>
					<input type="text" id="selectpage" class="input-block-level"name="receiveId" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label" style="text-align: center;margin-right: 15px;"value="${mail.mailInfo }">内容</label>
				<textarea id="editor_id" name="mailInfo" style="width:700px;height:300px;">
					&lt;strong&gt;HTML内容&lt;/strong&gt;
				</textarea>
			</div>
			<div class="form-group">
				<div class="col-sm-4 col-sm-offset-2" style="margin-bottom: 20px;">
					<button class="btn btn-primary" onclick="send()" >发送</button>
					<button class="btn btn-primary" onclick="save()">保存到草稿</button>
				</div>
			</div>
		</form>
		<script>
			var tag_data = ${jsonUsers};
			$('#selectpage').selectPage({
				showField: 'userName', //设置选框中显示的文本
				keyField: 'id', //设置下拉列表项目中项目的KEY值，用于提交表单
				data: tag_data, //数据源，可以是JSON数据格式，也可以是URL
				pageSize: 5 //页面大小
			})
		</script>
		<script>
			function send(){
				document.myform.action="writeMail.do";
				document.myform.submit();
				//var url="writeMail.do";
				//var params=$("#myform").serialize();
				 //异步处理
		        //$.post(url,params);
			}
		</script>
		<script>
			function save(){
				document.myform.action="http://localhost:8080/back0806/mail/save.do";
				document.myform.submit();
			}
		</script>
	</body>

</html>